package com.example.animationmodule

import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.annotation.RequiresApi
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.android.baselibrary.arouter.ArouterContains
import com.android.baselibrary.base.BaseActivity
import com.android.baselibrary.base.BasePath
import com.example.animationmodule.adapter.AnimationMainAdapter
import com.example.animationmodule.databinding.ActivityAnimationMainBinding
import com.example.animationmodule.loading.LoadDialog

@Route(path = ArouterContains.ANIMATION_MODEL)
class AnimationMainActivity : BaseActivity<ActivityAnimationMainBinding>() {


    override fun getLayoutId(): Int {
        // LottieAnimationView
        return R.layout.activity_animation_main
    }

    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
    override fun initView() {
        val adapter = AnimationMainAdapter()
        mBinding.animationRecycler.adapter = adapter
        adapter.addData(mData)
        adapter.setOnItemClickListener { data, _ ->
            if (data.path == AnimationPath.LoadingView){
                val loadDialog = LoadDialog(this)
                 loadDialog.show()
            }else{
                ARouter.getInstance().build(data.path).navigation()
            }

        }

    }

    override fun initListener() {

    }


    private val mData by lazy {
        mutableListOf(
            BasePath("LottieAnimationView", AnimationPath.LottieAnimationView),
            BasePath("LiveStartCountDownTextView",AnimationPath.LiveStartView),
            BasePath("CustomDrawableActivity",AnimationPath.CustomDrawableView),
            BasePath("ViewAnimatorActivity",AnimationPath.ViewAnimator),
            BasePath("LoadingView",AnimationPath.LoadingView),
            BasePath("Coil图片框架基本使用",AnimationPath.Coil_ImageLoader),
            BasePath("路径动画-PathMeasure",AnimationPath.PathMeasureView),
            BasePath("二维码扫描e",AnimationPath.ScanView)
        )
    }


}